package cn.bdqn.dao;

import java.sql.*;

//数据层的父类
public class BaseDao {
    //查询方法
    public void executeQuery(){

    }
    //非查询方法
    public int executeNunQuery(String sql){
        int rs=0;
        try {
            Class.forName("com.mysql.jdbc.Driver");
            String connstr="jdbc:mysql:///myschool?characterEncoding=utf8";
            //创建连接对象
            Connection conn= DriverManager.getConnection(connstr,"root","root");
            //创建表达式对象
            Statement stmt = conn.createStatement();
            //执行SQL语句，返回一个结果集对象
            rs = stmt.executeUpdate(sql);
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return rs;
    }
}
